<script>
jQuery(document).ready(function($){
	var dates = $( "#searchFromDate, #searchToDate" ).datepicker({
		dateFormat: "dd-mm-yy",
		showOn: 'both',
		buttonImage: '<?php echo CSS_IMAGES_JS_BASE_URL;?>images/calendar.gif',
		buttonImageOnly: true,
		buttonText: 'Choose',
		defaultDate: "+0w",
		numberOfMonths: 1,
		onSelect: function( selectedDate ) {
			var option = this.id == "searchFromDate" ? "minDate" : "maxDate",
				instance = $( this ).data( "datepicker" );
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates.not( this ).datepicker( "option", option, date );
		}
	});

	jQuery("#frmSearch").validationEngine();

	jQuery("#searchField").change(function()
	{
	  if(jQuery("#searchString").hasClass("validate[required]"))
			{
			jQuery("#searchString").removeClass("validate[required]");
			jQuery(".searchStringformError").hide();
			}
	});

	jQuery("#search").click(function()
	{
		if(jQuery("#searchField").val()!="")
		{
		 jQuery("#searchString").addClass("validate[required]");
		 var error=jQuery('#frmSearch').validationEngine('validateField', '#searchString');
		 if(jQuery("#searchString").hasClass("validate[required]") && error==true)
			{
			jQuery(".searchStringformError").show();
			}
		 }
	});
});

function refreshSearchOption(val)
{
	if(val=='custom'){
		document.getElementById('custom_range_tr').style.display='';
	}else{
		document.getElementById('searchFromDate').value='';
		document.getElementById('searchToDate').value='';
		document.getElementById('custom_range_tr').style.display='none';
	}
 }
 
 function alertmsg(){
	alert('You can not delete this system page.');
 }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="maintable">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td valign="top"><table width="100%" align="center" cellpadding="2" cellspacing="2" border="0">
              <tr>
                <td valign="top" bgcolor="#FFFFFF"><form name="frmSearch" id="frmSearch" method="post" action="<?php echo $search_link;?>">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td class="block-block">Content Search Panel</td>
                      </tr>
                      <tr>
                        <td class="border"><table width="100%" border="0" cellspacing="2" cellpadding="0">
                            <tr>
                              <td width="14%" align="right"><strong>Search By :</strong></td>
                              <td width="86%" valign="top" colspan="3">&nbsp;<select name="searchField" id="searchField" class="SELECT">
                                  <option value="" >Select Search Type</option>
                                  <option value="title" <?php if($params['searchField']=='title') echo 'selected';?> >Title</option>
                                  <option value="url" <?php if($params['searchField']=='url') echo 'selected';?>>URL</option>
                                </select>
                                &nbsp;
                                <input type="text" name="searchString" id="searchString" class="textbox" value="<?php echo $params['searchString'];?>" />
                                &nbsp;
                                <input type="submit" class="textbox" value="Search" id="search"/>
                                &nbsp;
                                <input name="btnShowAll" type="button" class="textbox" value="Show All" onClick="javascript:show_all('<?php echo $showall_link; ?>');" />
                              </td>
                            </tr>
                            <tr>
                              <td align="right"><strong>Modified Date:</strong> </td>
                              <td valign="top" nowrap="nowrap">&nbsp;<select name="searchText" id="searchText" onchange="javascript: refreshSearchOption(this.value);">
							  <option value="all_time" <?php echo ($params['searchText']=='all_time')?'selected':'';?>>All Time</option>
							  <option value="this_month" <?php echo ($params['searchText']=='this_month')?'selected':'';?>>This Month</option>
							  <option value="last_month" <?php echo ($params['searchText']=='last_month')?'selected':'';?>>Last Month</option>
							  <option value="last_3_months" <?php echo ($params['searchText']=='last_3_months')?'selected':'';?>>Last 3 Months</option>
							  <option value="last_6_months" <?php echo ($params['searchText']=='last_6_months')?'selected':'';?>>Last 6 Months</option>
							  <option value="this_year" <?php echo ($params['searchText']=='this_year')?'selected':'';?>>This Year</option>
							  <option value="last_year" <?php echo ($params['searchText']=='last_year')?'selected':'';?>>Last Year</option>
							  <option value="custom" <?php echo ($params['searchText']=='custom')?'selected':'';?>>Custom Range</option>
							  </select></td>
                              <td align="center">&nbsp;</td>
                              <td colspan="3">&nbsp;</td>
                            </tr>
                            <tr id="custom_range_tr" style="display:<?php echo ($params['searchText']=='custom')?'':'none';?>;">
                              <td align="right"><strong>From :</strong> </td>
                              <td colspan="5" valign="top" nowrap="nowrap">&nbsp;<input type="text" name="searchFromDate" id="searchFromDate" style="margin-right:5px;" size="10" value="<?php echo $params['searchFromDate'];?>" readonly="" onclick="this.value=''" />
                              <strong>To
                              <input type="text" name="searchToDate" id="searchToDate" style="margin-right:5px;" size="10" value="<?php echo $params['searchToDate'];?>" readonly="" onclick="this.value=''" />
                              </strong>&nbsp;&nbsp;</td>
                            </tr>
							<tr>
								<td align="right"><strong>Display #:</strong> </td>
								<td colspan="3">&nbsp;<select name="searchDisplay" id="searchDisplay" onchange="refreshSerachDesplay();">
									<option value="5" <?php echo ($params['searchDisplay']==5)?'selected':''?>>5</option>
									<option value="10" <?php echo ($params['searchDisplay']==10)?'selected':''?>>10</option>
									<option value="15" <?php echo ($params['searchDisplay']==15)?'selected':''?>>15</option>
									<option value="20" <?php echo ($params['searchDisplay']==20)?'selected':''?>>20</option>
									<option value="25" <?php echo ($params['searchDisplay']==25)?'selected':''?>>25</option>
									<option value="30" <?php echo ($params['searchDisplay']==30)?'selected':''?>>30</option>
									<option value="35" <?php echo ($params['searchDisplay']==35)?'selected':''?>>35</option>
									<option value="40" <?php echo ($params['searchDisplay']==40)?'selected':''?>>40</option>
									<option value="45" <?php echo ($params['searchDisplay']==45)?'selected':''?>>45</option>
									<option value="50" <?php echo ($params['searchDisplay']==50)?'selected':''?>>50</option>
								</select><input type="hidden" name="sortType" id="sortType" value="<?php echo $params['sortType'];?>" />
                                <input type="hidden" name="sortField" id="sortField" value="<?php echo $params['sortField'];?>" /></td>
							</tr>
                          </table></td>
                      </tr>
                    </table>
                  </form></td>
              </tr>
              <tr>
                <td valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="block-block">Content Management System (<?php echo $total_rows;?>)</td>
                    </tr>
                    <tr>
                      <td align="left" valign="top" class="border"><table width="100%" border="0" cellspacing="2" cellpadding="2">
                          <tr>
                            <td width="94%">&nbsp;</td>
                            <td width="2%" align="right" colspan="3"><a href="<?php echo $reload_link?>" title=" Refresh the page "> <img border="0" src="<?php echo CSS_IMAGES_JS_BASE_URL;?>images/icon_reload.gif" alt="" /></a></td>
                           <td width="2%" align="right"><a href="<?php echo $add_link?>" title=" Add Content "><img src="<?php echo CSS_IMAGES_JS_BASE_URL;?>images/plus_icon.gif" border="0" alt="" /></a></td>
                           <!--  <td width="2%" align="right"><a href="javascript:;" onclick="javascript: Delete_all('content/deleteall/');" title=" Delete All "><img src="<?php echo CSS_IMAGES_JS_BASE_URL;?>images/delete_icon.gif" alt="" border="0"></a></td>   -->                         
                          </tr>
                        </table>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td align="left" valign="top" style="padding:10px 0px 10px 0px;"><table width="100%" border="0" cellspacing="1" cellpadding="0">
                                <tr align="center">
                                   <!--<td width="2%" class="block-block"><input type="checkbox"  name="checkAllAuto" id="checkAllAuto" value="0"/></td>-->
								    <td width="2%" class="block-block" align="center">SL</td>
								  <td class="block-block" align="left" width="30%"><?php echo tableOrdering("Title","title",$params['sortField'],$params['sortType']); ?></td>
                                  <td width="52%" nowrap="nowrap" class="block-block" align="left"><?php echo tableOrdering("URL","url",$params['sortField'],$params['sortType']); ?></td>
                                  <td width="10%" nowrap="nowrap" class="block-block"><?php echo tableOrdering("Modified Date","modified_date",$params['sortField'],$params['sortType']); ?> </td>
							 <td width="2%" class="block-block">Edit</td>
                                 	 <td width="2%" class="block-block">Delete</td><!-- -->
                                </tr>
                                <?php
								if($recordset)
								{
									for($i=0; $i<count($recordset); $i++)
									{
										$editLink = str_replace("{{ID}}",$recordset[$i]['id'],$edit_link);
										$deleteLink = str_replace("{{ID}}",$recordset[$i]['id'],$delete_link);
										if($i%2==0) $style_td ='gray-block' ; else $style_td ='blue-block';
								?>
                                <tr align="center" class="<?php echo $style_td;?>">
                                  <!--<td><input type="checkbox" name="check_box" value="<? //echo $recordset[$i]['id'];?>" /></td>-->
								  <td align="center"><?php echo $i+$startRecord+1; ?></td>
                                  <td align="left"><?php echo $recordset[$i]['title'];?></td>
                                  <td align="left"><?php echo $recordset[$i]['url'];?><!--<a href="<?php echo front_base_url().'page/'.$recordset[$i]['url'].'/';?>" target="_blank"></a>--></td>
                                  <td><?php echo formate_date($recordset[$i]['modified_date']);?></td>
								  <td><a href="<?php echo $editLink;?>" title=" Edit Content "><img src="<?php echo CSS_IMAGES_JS_BASE_URL;?>images/edit_icon.gif" alt="" border="0"></a></td>
                                 <td><?php if($recordset[$i]['content_page_type'] == 0 ){?><a href="javascript:Delete('<?php echo $deleteLink;?>');" title=" Delete Content "><img src="<?php echo CSS_IMAGES_JS_BASE_URL;?>images/delete_icon.gif" alt="" border="0"></a><?php }else{ ?>  <a href="javascript:alertmsg();" title=" Delete Content "><img src="<?php echo CSS_IMAGES_JS_BASE_URL;?>images/delete_icon.gif" alt="" border="0"></a>   <?php   }?></td><!-- -->
								</tr>
                                <?php
									}
								}
								else
								{
								?>
                                <tr>
                                  <td height="100" colspan="7" align="center" valign="middle" class="blue-block">No Records Found</td>
                                </tr>
								<?php
								}
								?>
								<tr>
								   <td colspan="7" align="center">&nbsp;</td>
								</tr>
								<tr>
								   <td colspan="7" align="center"><?php echo $this->pagination->create_links();?></td>
								</tr>
                              </table></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
